﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class user_Default : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            db();
        }
    }
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem
        || e.Item.ItemType == ListItemType.Item)
        {
            string isenable = (e.Item.FindControl("lblIsEnable") as Label).Text;
            if (isenable == "True")
                (e.Item.FindControl("lblIsEnable") as Label).Text = "正常";
            else
                (e.Item.FindControl("lblIsEnable") as Label).Text = "禁用";
        }
    }
    void db()
    {
        CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
        var users = dal.User.AsQueryable();
        var name = Server.UrlDecode(Request["name"]);
        var rolename = Server.UrlDecode(Request["rolename"]);
        if (!string.IsNullOrEmpty(name))
            users = users.Where(x => x.LoginName.Contains(name));
        if (!string.IsNullOrEmpty(rolename))
            users = users.Where(x => x.Role.RoleName.Contains(rolename));
        Repeater1.DataSource = users;
        Repeater1.DataBind();
    }
}